<template>
  <div class="content-child">
    <div class="content-child-main">
      <div class="child-main-left">
        <flow-type />
      </div>
      <div class="child-main-right">
        <div v-show="curFlowType === flowCheck" class="child-main-right-flow">
          <flow-check-main />
        </div>
        <div v-show="curFlowType === flowStart" class="child-main-right-flow">
          <flow-start-main />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import { defineComponent, reactive, toRefs, onBeforeUnmount, onMounted } from 'vue';
  import FlowType from '@/views/board-home/components/flow-type.vue';
  import FlowCheckMain from '@/views/board-home/components/flow-check-main.vue';
  import FlowStartMain from '@/views/board-home/components/flow-start-main.vue';
  import VueEvent from '@/helper/event';
  import { HOME_FLOW_SWITCH, HOME_FLOW_CHECK, HOME_FLOW_START } from '@/helper/constant';
  export default defineComponent({
    name: 'FlowMain',
    components: {
      FlowType,
      FlowCheckMain,
      FlowStartMain,
    },
    setup() {
      const state = reactive({
        curFlowType: HOME_FLOW_CHECK,
        flowCheck: HOME_FLOW_CHECK,
        flowStart: HOME_FLOW_START,
      });
      const methods = {
        watchFlowType(type) {
          state.curFlowType = type;
        },
      };
      onMounted(() => {
        VueEvent.on(HOME_FLOW_SWITCH, methods.watchFlowType);
      });
      onBeforeUnmount(() => {
        VueEvent.off(HOME_FLOW_SWITCH);
      });
      return {
        ...toRefs(state),
        ...methods,
      };
    },
  });
</script>
<style>
  .child-main-right .right-content-main::-webkit-scrollbar {
    width: 0;
    height: 0;
  }
</style>
<style scoped lang="less">
  .content-child {
    width: 100%;
    box-sizing: border-box;
    background-color: #ffffff;
    .content-child-main {
      width: 100%;
      box-sizing: border-box;
      display: flex;
      .child-main-left {
        width: 210px;
      }
      .child-main-right {
        width: 670px;
      }
      .child-main-right-flow {
        height: 100%;
      }
    }
  }
</style>
